from website.liankebio.api import search_product, get_product_detail
from website.liankebio.utils import extract_search_detail, extract_product_detail


def get_des_by_procode(procode: str) -> str:
    """根据商品货号获取商品详情

    Args:
        procode (str): 商品货号

    Returns:
        str: 商品详情
    """
    search_data = search_product(procode)
    pro_list = extract_search_detail(search_data)
    for item in pro_list:
        if item["procode"] == procode:
            pro_url = item["url"]
            pro_detail = get_product_detail(pro_url)
            return extract_product_detail(pro_detail)
    return "暂无商品详情"
